package Presentation;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.web.WebView;


public class BoutonRetour extends Button
{
    FenetrePrincipale fp;
    
    public BoutonRetour(final FenetrePrincipale fp, int l, int h){
        super("Retour");
        this.setPrefSize(l,h);
        this.fp=fp;
        
        
        this.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
                if(fp.enabledRetour){
                    fp.bAller.setEnabled(true);
                    fp.index++;
                    if(fp.index>=fp.navigList.size()-1){
                        setEnabled(false);
                    }
                    fp.tfURL.setText(fp.navigList.get(fp.index).getEngine().getLocation());
                    fp.navigList.get(fp.index-1).setVisible(false);                
                    fp.navigList.get(fp.index).setVisible(true);
                }
            }
        });
    }
    
    public void setEnabled(boolean b){
        fp.enabledRetour=b;
        if(b){
            setStyle("-fx-base: LIGHTGREY;");
        }else{
            setStyle("-fx-base: CRIMSON;");
        }
    }
    
    
}
